<?php

class Window {

    //Variable pour les dimentions de la fenêtre
    public $l1;
    public $l2;
    public $l3;
    public $l4;
    public $l5;
    public $l6;
    public $l7;
    public $l8;
    public $l9;
    public $type; // Type de la fenêtre
    public $idFrame; //Matière du cadre
    public $hasSunBlind; //s'il y a des stores
    public $idGlass; //Type de vitrage
    
    //Variable pour le calcul de l'algo
    public $A1;
    public $A2;
    public $A3;
    public $A4;
    public $A5;
    public $LT1;
    public $LT2;
    public $LT3;
    public $LT4;
    public $LT5;
    public $LT6;

    public function __construct($type, $idFrame, $idGlass, $hasSunBlind, $l1, $l2, $l3, $l4, $l5, $l6, $l7, $l8, $l9) {
        $this->idFrame = $idFrame;
        $this->idGlass = $idGlass;
        $this->hasSunBlind = $hasSunBlind;
        $this->type = $type;

        $this->l1 = $l1;
        $this->l2 = $l2;
        $this->l3 = $l3;
        $this->l4 = $l4;
        $this->l5 = $l5;
        
        $this->A1 = $l1 * $l2;      
        $this->LT1 = 2 * ($l1 + $l2);
        

        //Selon le type de la fenêtre des valeurs sont fixes
        switch ($type) {
            case 1:
                $this->l6 = 0.12;
                $this->l7 = 0.13;
                $this->l8 = 0.11;
                $this->l9 = 0.14;
                
                $this->A2 = $this->l1 * $this->l6;
                    
                $this->LT2 = $this->l1 - $this->l3;
                $this->LT3 = $this->l2 - $this->l4 - $this->l5 - $this->l6;
                $this->LT4 = 2 * ($this->LT2 + $this->LT3);
                $this->A3 = $this->LT2 * $this->LT3;
                $this->A4 = $this->A1 - $this->A3;
                $this->A5 = $this->A4 - $this->A2;
                 
                break;

            case 2:
                $this->l7 = $l7;

                $this->l6 = 0.12;
                $this->l8 = 0.11;
                $this->l9 = 0.14;
                
                $this->A2 = $this->l1 * $this->l7;
               
                $this->LT2 = $this->l1 - $this->l3 - $this->l4;
                $this->LT3 = $this->l2 - $this->l5 - $this->l6 - $this->l7;
                $this->LT4 = 2 * ($this->LT2 + (2 * $this->LT3));
                $this->A3 = $this->LT2 * $this->LT3;
                $this->A4 = $this->A1 - $this->A3;
                $this->A5 = $this->A4 - $this->A2;
                
                break;
            
            case 3:
                $this->l7 = $l7;

                $this->l6 = 0.12;
                $this->l8 = 0.11;
                $this->l9 = 0.14;
                
                $this->A2 = $this->l1 * $this->l7;
                
                $this->LT2 = $this->l1 - $this->l3 - $this->l4;
                $this->LT3 = $this->l2 - $this->l5 - $this->l6 - $this->l7;
                $this->LT4 = 2 * ($this->LT2 + (3 * $this->LT3));
                $this->A3 = $this->LT2 * $this->LT3;
                $this->A4 = $this->A1 - $this->A3;
                $this->A5 = $this->A4 - $this->A2;
                break;
            
            case 4:
                $this->l7 = $l7;

                $this->l6 = 0.12;
                $this->l8 = 0.11;
                $this->l9 = 0.14;
                
                $this->A2 = $this->l1 * $this->l7;
                
                $this->LT2 = $this->l1 - $this->l3 - $this->l4;
                $this->LT3 = $this->l2 - $this->l5 - $this->l6 - $this->l7;
                $this->LT4 = 2 * ($this->LT2 + (4 * $this->LT3));
                $this->A3 = $this->LT2 * $this->LT3;
                $this->A4 = $this->A1 - $this->A3;
                $this->A5 = $this->A4 - $this->A2;
                break;

            case 5:
                $this->l7 = $l7;
                $this->l8 = $l8;

                $this->l6 = 0.12;
                $this->l9 = 0.14;
                
                $this->A2 = $this->l1 * $this->l8;
                
                $this->LT2 = $this->l1 - $this->l3 - $this->l4;
                $this->LT3 = $this->l2 - $this->l5 - $this->l6 - $this->l7 - $this->l8;
                $this->LT4 = 4 * ($this->LT2 + $this->LT3);
                $this->A3 = $this->LT2 * $this->LT3;
                $this->A4 = $this->A1 - $this->A3;
                $this->A5 = $this->A4 - $this->A2;
                break;

            case 6:
                $this->l7 = $l7;
                $this->l8 = $l8;
                $this->l9 = $l9;

                $this->l6 = 0.12;
                
                $this->A2 = $this->l1 * $this->l9;
               
                $this->LT2 = $this->l1 - $this->l3 - $this->l4;
                $this->LT3 = $this->l7;
                $this->LT5 = $this->l1 - $this->l3;
                $this->LT6 = $this->l2 - $this->l5 - $this->l6 - $this->l7 - $this->l8 - $this->l9;
                $this->LT4 = 2 * ($this->LT2 + (2 * $this->LT3) + $this->LT5 + $this->LT6);
                $this->A3 = ($this->LT2 * $this->LT3) + $this->LT6;
                $this->A4 = $this->A1 - $this->A3;
                $this->A5 = $this->A4 - $this->A2;
                break;

            default:
                echo "Type de la fenêtre non connue...";
                break;
        }
        
                
       
        
       
         
    }

}
?>